package educrypt.analysis;

public class FrequencyPair implements Comparable<FrequencyPair> {

	private Double value;
	private String symbols;

	public FrequencyPair(String symbols, double percentage) {
		this.value = percentage;
		this.symbols = symbols;
	}

	public double getPercentage() {
		return value;
	}

	public String getSymbols() {
		return symbols;
	}

	public String toString() {
		return symbols + ":" + value;
	}

	@Override
	public boolean equals(Object o) {
		return o instanceof FrequencyPair
				&& ((FrequencyPair) o).symbols == (this.symbols)
				&& ((FrequencyPair) o).value == (this.value);
	}

	@Override
	public int hashCode() {
		return symbols.hashCode() + value.hashCode();
	}

	@Override
	public int compareTo(FrequencyPair p) {
		// alphabetic order
		return this.symbols.compareTo(p.symbols);
	}
}

